package com.itheima.homework;

import java.util.Scanner;

public class proTest03 {
    public static void main(String[] args) {
        double pay;
        int integral = 1000;
        double money = 500.0;
        Scanner sc = new Scanner(System.in);
        System.out.println("请选择付款类型: 0:普通顾客, 1: 会员顾客");
        int type;
        while (true) {
            type = sc.nextInt();//选择顾客类型 0:普通用户 1:会员用户
            if (type != 0 && type != 1){
                System.out.println("输入有误,请重新选择顾客类型:");
            }else {
                break;
            }
        }
        // }
        System.out.println("请输入付款金额:");
        int cost;
        while(true){
            cost = sc.nextInt();//输入消费金额
            if(cost < 0){
                System.out.println("输入有误,请重新输入付款金额:");
            }else{
                break;
            }
        }
        if (type == 0) {
            method(cost, money);
        } else {
            method(cost, money, integral);
        }

    }

    public static void method(double cost, double money) {
        System.out.println("付款成功");
        System.out.println("本次消费" + cost + "元,收您:" + money + "元,找零:" + (money - cost) + "元");
    }

    public static void method(double cost, double money, int integral) {
        System.out.println("付款成功");
        System.out.println("您本次一共消费:" + cost + "元");
        if ((integral / 10) >= cost) {
            System.out.println("您的账户剩余积分:" + (int) (integral - cost * 10));
            System.out.println("您的账户余额为:" + money + "元");
        } else {
            if (cost > 100) {
                int i = (int) (cost - (integral) / 10) / 100;
                System.out.println("您的账户剩余积分:" + (i * 500));
                System.out.println("您的账户余额为:" + (money - integral / 10) + "元");
            }
        }
    }
}
